import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.function.Consumer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-09-02
 * Time: 13:57
 */
@FunctionalInterface
interface NoParameterNoReturn{
    void test();
}
//无返回值一个参数
@FunctionalInterface
interface OneParameterNoReturn {
    void test(int a);
}
//有返回值无参数
@FunctionalInterface
interface NoParameterReturn {
    int test();
}
//有返回值一个参数
@FunctionalInterface
interface OneParameterReturn {
    int test(int a);
}
public class Test78 {
    public static void main(String[] args) {
        int f=999;
        NoParameterNoReturn noParameterNoReturn1=()->{
            //f=9;
            System.out.println("无返回值无参数");
            System.out.println(f);
        };
        noParameterNoReturn1.test();

        OneParameterNoReturn oneParameterNoReturn=a-> System.out.println("一个参数无返回值"+a);
        oneParameterNoReturn.test(5);

        NoParameterReturn noParameterReturn=()->{
            System.out.println("没有参数，但是有一个返回值");
            return 99;
        };
        System.out.println(noParameterReturn.test());

        OneParameterReturn oneParameterReturn= a->9999;

        System.out.println(oneParameterReturn.test(67));

        PriorityQueue<Integer> maxHeap=new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        });
        PriorityQueue<Integer> maxHeap1=new PriorityQueue<>((x,y)->{return x.compareTo(y);});

        ArrayList<String> list=new ArrayList<>();
        list.add("hello");
        list.add("gfu");
        list.add("llo");
        list.add("dfghjk");
        list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.print(s+" ");
            }
        });
        System.out.println("   ");
        list.forEach(s -> System.out.print(s+" "));
        System.out.println();

        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }
        });
        System.out.println(list);

        ArrayList<String> list1=new ArrayList<>(list);
        list1.sort((o1,o2)->o1.length()-o2.length());
        System.out.println(list1);
    }
}

class Test23{
    public void func(){
        System.out.println("sdfghjkl");
    }
}

class Test33{
    public static void main(String[] args) {
        int a=7989;
        new Test23(){
            //a=89;
            @Override
            public void func() {
                System.out.println("内部类，重写了一个方法");
                System.out.println(a);
            }
        };
    }
}


